<script type="text/javascript">
    	$(document).ready(function () {

    	    //Deals with Idle session
    	    var timeout = <?php echo sfConfig::get("app_refreshaccueil", 60)*1000 ?>; //Timer à 60 secondes d'inactivité avant le refresh

    	     $(document).bind("idle.idleTimer", function () {
    	    	 location.reload(true);
    	     }); 

    	     $.idleTimer(timeout);
    	});
</script>
<fieldset style="width: 70%; float: left">
	<legend>Informations du jour</legend>
	<?php include_partial('news')?>

<div style="clear: both;">
<?php if(count($anniversaires)>0):?>
<button class="button_c" style="width:90%; ">Nous souhaitons un joyeux anniversaire à 
<?php 
$connecteur = '';
$i = 0;
foreach ($anniversaires as $anniversaire) {
	echo $connecteur . $anniversaire['prenom'] . ' ' . $anniversaire['nom'];
	$i++;
	$connecteur = ($i==count($anniversaires)-1)? ' et ' : ' , ';
}?>
</button>
<?php endif;?>
</div>
</fieldset>

<fieldset style="width: 25%; float: right">
	<legend>Entités</legend>
	<?php foreach ($entites as $entite):?>
	<?php echo link_to('<button class="button_a" type="button" style="height:75px;">' . $entite['nom'] . '</button>', 'hometouch/utilisateurs?entite=' . $entite['id']);?>
	<?php endforeach;?>
</fieldset>

<fieldset style="width: 25%; float: right">
	<legend>Autres accès</legend>
	<a href="<?php echo url_for('@documentationTouch')?>">
		<button class="button_b" type="button" style="width: 90%;">
			<img alt="" src="/images/icons/48/documentation.png"><br />
			Documentation
		</button> </a>
</fieldset>

<fieldset style="width: 25%; float: right">
	<legend>Perte des points</legend>
	<div id="madiv"> 
		<button class="button_c" style="width: 90%;">
			<ul>
			<?php foreach ($pertepoints as $perte):?>
				<li><?php echo $perte['personne']['prenom'] . ' ' . $perte['personne']['nom'] . ' :' . $perte['points']?>
				<?php endforeach;?>
			</ul>
		</button>
	</div> 
</fieldset>

<div style="clear:both; width:100%"></div>

<?php 
	if(count($messages)>0 && count($notifications)>0 && count($communications)>0 ){
	$widthMsg = '44%';
	$widthNotif = '25%';
	$widthButtons = '90%';
	$widthComm = '25%';
	$heightButtons = '75px';
	$floatMsg = 'left';
	$floatButtons = 'none';
}elseif(count($messages)>0 && count($notifications)>0 && count($communications)==0){
	//pas de communications
	$widthMsg = '73%';
	$widthNotif = '25%';
	$widthButtons = '90%';
	$widthComm = '0%';
	$heightButtons = '75px';
	$floatMsg = 'left';
	$floatButtons = 'none';
}elseif(count($messages)==0 && count($notifications)>0 && count($communications)>0){
	//pas de messages
	$widthMsg = '0%';
	$widthNotif = '70%';
	$widthButtons = '180px';
	$widthComm = '25%';
	$heightButtons = '75px';
	$floatMsg = 'left';
	$floatButtons = 'left';
}elseif(count($messages)>0 && count($notifications)==0 && count($communications)>0){
	//pas de notifications
	$widthMsg = '70%';
	$widthNotif = '0%';
	$widthButtons = '180px';
	$widthComm = '25%';
	$heightButtons = '75px';
	$floatMsg = 'left';
	$floatButtons = 'left'; //none
}else{
	$widthMsg = '100%';
	$widthNotif = '100%';
	$widthComm = '100%';
	$widthButtons = '180px';
	$heightButtons = '75px';
	$floatMsg = 'none';
	$floatButtons = 'left';
}
	if(count($notifications)>0){
	
			?>
			<fieldset style="width: <?php echo $widthNotif?>; float: left">
			<legend>Il y a des notifications à consulter pour : </legend>
			<div id="zone_notifications">
				<?php 
				$tabnotif = array();
				foreach ($notifications as $notif):?>
					
					<?php 
					if(!in_array($notif['personne']['id'], $tabnotif)){
						?> 
						<a href="<?php echo url_for('hometouch/login?personne=' . $notif['personne']['id']) ?>">
							<button class="button_a" type="button" style="width:<?php echo $widthButtons?>;float:<?php echo $floatButtons?>;height:<?php echo $heightButtons?>">
								<?php echo $notif['personne']['name'];?>
							</button>
						</a>
						
					<?php 
					}
					$tabnotif[] = $notif['personne']['id'];
	
				endforeach;?>
				</div>
			</fieldset>
	<?php
	}
	?>
	
	<?php 

	if(count($messages)>0){
	
			?>
			<fieldset style="width: <?php echo $widthMsg?>; float: <?php echo $floatMsg?>">
			<legend>Messages</legend>
			<?php include_partial('messages/showMessagesList', array('messages' => $messages));?>
			</fieldset>
	<?php
	}
	
	
	?>
	
	<?php 
	if(count($communications)>0){
	
			?>
			<fieldset style="width: <?php echo $widthComm?>; float: right">
			<legend>Communication(s)</legend>
			<?php include_partial('messages/showCommunicationList', array('communications' => $communications));?>
			</fieldset>
	<?php
	}
	
	
	?>
